<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function currying() {
            const args = Array.prototype.slice.call(arguments)
            console.log(args, "1");

            const inner = function inner() {
                args.push(...arguments);
                console.log(args,"2");
                return inner;
            }
            inner.__proto__[Symbol.toPrimitive] =inner.toString=inner.getValue = function () {
                return args.reduce((res, ele) => {
                    return res + ele;
                }, 0);
                // console.log(args, "2");
            }
            // console.log(inner,"3");

            return inner;
            // return currying;
        }
        const res = currying(1, 2, 3, 4, 5)(6, 7)(8, 9, 10)
        // const resNum = res.getValue()
        // console.log(resNum);
        console.log(res-0,"res");
    </script>
</body>

</html>